const host = "https://smartgymdemo.ocmcom.com/smallapp/MemberShip";
var MD5 = require("md5.js");
function request(obj){
  var timestamp = Date.parse(new Date())/1000;
  var key = "a5a20976a84aa4cd88ad1c9024fd82d1";
  var url = host + obj.url
  obj.data.time = timestamp;
  obj.data.sign = MD5.hexMD5(key + "_" + timestamp);
  obj.data.shop_id = obj.data.shop_id ? obj.data.shop_id:wx.getStorageSync("shop_id");
  console.log("net request",obj);
  wx.request({
    url: url,
    data: obj.data,
    method:"POST",
    success: function (res) {console.log("net success:",res); if (obj.success) obj.success(res);},
    fail: function (res) { console.log("net fail:", res); if (obj.fail) obj.fail(res);},
    complete: function (res) { if (obj.complete) obj.complete(res);},
  })

}

module.exports={
  request: request
}